package it.polimi.reTraveldream.entities;


import it.polimi.reTravelDream.dto.TravelPackageDTO;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;


/**
 * Entity implementation class for Entity: TravelPackage
 *
 */
@Entity
@Table(name="TRAVEL_PACKAGES")
@NamedQueries({
	@NamedQuery(name=TravelPackage.FIND_PACKAGE_BY_KEYWORD,
            query="SELECT t FROM TravelPackage t WHERE t.name LIKE :keyword OR t.keyWord1 LIKE :keyword OR "
            		+ "t.keyWord2 LIKE :keyword OR t.keyWord3 LIKE :keyword"),	
	@NamedQuery(name=TravelPackage.FIND_ALL_PACKAGES,
		query="SELECT t1 FROM TravelPackage t1"),

})

public class TravelPackage implements Serializable {

	private static final long serialVersionUID = 1L; 
	public static final String FIND_PACKAGE_BY_KEYWORD = "TravelPackage.findPackageByKey";		
	public static final String FIND_ALL_PACKAGES= "TravelPackage.findAllPackages";		
	public static final String GET_PACKAGE_BY_ID="TravelPackage.getPAckageByID";


	
	@Id
	private int id;
	private String name;
	private String city;
	private String Description;
	private String keyWord1;
	private String keyWord2;
	private String keyWord3;
	
	@Temporal(TemporalType.TIMESTAMP)
	private Date arrivo;
	
	private int numberOfNights;
	
	private int numberOfPerson;
	private List<Flight> availableFlights;
	private List<Hotel> availableHotels;
	private List<Excursion> availableExcursions;


	public TravelPackage() {
		
	}
	
	public TravelPackage(TravelPackageDTO travelPackageDTO,
			List<Flight> flightToAdd, 
			List<Hotel> hotelToAdd,
			List<Excursion> excursionToAdd) {
		super();
		//this.availableFlights=new ArrayList<Flight>();
		//this.availableHotels= new ArrayList<Hotel>();
		//this.availableExcursions=new ArrayList<Excursion>();
		this.id=travelPackageDTO.getId();
		this.name=travelPackageDTO.getPackageName();
		this.Description=travelPackageDTO.getDescription();
		this.setCity(travelPackageDTO.getCity());
		this.keyWord1=travelPackageDTO.getKeyWord1();
		this.keyWord2=travelPackageDTO.getKeyWord2();
		this.keyWord3=travelPackageDTO.getKeyWord3();
		this.numberOfPerson=travelPackageDTO.getNumberOfPerson();
		this.availableFlights=flightToAdd;
		this.availableHotels=hotelToAdd;
		this.availableExcursions=excursionToAdd;
		this.arrivo=travelPackageDTO.getArrivo();
		this.numberOfNights=travelPackageDTO.getNumberOfNights();
		
	} 
	
	public void addFlights(List<Flight> flightsToAdd) {
		this.availableFlights=flightsToAdd;
	}
	
	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}   
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}   
	public String getDescription() {
		return this.Description;
	}

	public void setDescription(String Description) {
		this.Description = Description;
	}
	public String getKeyWord1() {
		return keyWord1;
	}
	public void setKeyWord1(String keyWord1) {
		this.keyWord1 = keyWord1;
	}
	public String getKeyWord2() {
		return keyWord2;
	}
	public void setKeyWord2(String keyWord2) {
		this.keyWord2 = keyWord2;
	}
	public String getKeyWord3() {
		return keyWord3;
	}
	public void setKeyWord3(String keyWord3) {
		this.keyWord3 = keyWord3;
	}
	public int getNumberOfPerson() {
		return numberOfPerson;
	}
	public void setNumberOfPerson(int numberOfPerson) {
		this.numberOfPerson = numberOfPerson;
	}
	public List<Flight> getAvailableFlights() {
		return availableFlights;
	}
	public void setAvailableFlights(List<Flight> availableFlights) {
		this.availableFlights = availableFlights;
	}
	public List<Hotel> getAvailableHotels() {
		return availableHotels;
	}
	public void setAvailableHotels(List<Hotel> availableHotels) {
		this.availableHotels = availableHotels;
	}
	public List<Excursion> getAvailableExcursions() {
		return availableExcursions;
	}
	public void setAvailableExcursions(List<Excursion> availableExcursions) {
		this.availableExcursions = availableExcursions;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}



	public Date getArrivo() {
		return arrivo;
	}

	public void setArrivo(Date arrivo) {
		this.arrivo = arrivo;
	}

	public int getNumberOfNights() {
		return numberOfNights;
	}

	public void setNumberOfNights(int numberOfNights) {
		this.numberOfNights = numberOfNights;
	}
	
   
}
